<?php 
ini_set("output_buffering","Off");
ini_set("implicit_flush","On");
ini_set("zlib.output_compression","Off");

require_once("security.inc");
require_once("DataBase.inc");
require_once("applicants/app_fields.inc");
require_once("utils.inc");

if (isset($_POST["export"]) && $_POST["export"]=="excel") {
	header('Content-Type: application/excel');
	header('Content-Disposition: attachment;filename=applicants.xls');
	echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n";
	echo "<html><head><style type='text/css'>";
	echo "html, body, table { font-family: Verdana; font-size: 10pt; }\n";
	echo "table.applicants_table { border: 1px solid black;	empty-cells: show; }\n";
	echo "table.applicants_table th { background-color: #A0A0A0; padding: 2px 2px 2px 2px; border-right: 1px solid #505050; }\n";
	echo "table.applicants_table td { border-top: 1px solid black; border-right: 1px dotted #808080; height: 25px; }\n";
	echo "</style>";
	echo "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">";
	echo "</head><body>";
	include("applicants/applicants_functions.inc");
	include("applicants/applicants_table.inc");
	echo "</body></html>";
	die();
}

include("header.inc");

if (isset($_SESSION["debug"]) && $_SESSION["debug"]=="yes") {
	echo "<br/><br/>DEBUG:<br/>";
	echo "POST=";
	var_dump($_POST);
	echo "<br/><br/>";
}

global $retrieved_tables;
$retrieved_tables = array();
function &get_table_values($table) {
	global $retrieved_tables;
	if (!isset($retrieved_tables[$table]))
		$retrieved_tables[$table] = DataBase::select($table, null, null);
	return $retrieved_tables[$table];
}

flush();
include("applicants/applicants_functions.inc");
include("applicants/applicants_fields_selection.inc"); 
flush();
include("applicants/applicants_table.inc"); 
flush();
include("applicants/applicants_script.inc");

if (isset($_SESSION["debug"]) && $_SESSION["debug"]=='yes')
	echo "<iframe src='applicants/applicants_save.php' name='applicants_save' id='frame_applicants_save' width=400 height=200 frameborder='1'></iframe>";
else 
	echo "<iframe src='applicants/applicants_save.php' name='applicants_save' id='frame_applicants_save' width=1 height=1 frameborder='0'></iframe>";

?>


<?php include 'footer.inc';?>
